<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>工作台 - OA办公系统</title>
    <link href="${pageContext.request.contextPath}/css/tailwind.min.css" rel="stylesheet">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/fontawesome.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css">
    <script src="${pageContext.request.contextPath}/js/jquery-3.6.0.js"></script>
</head>
<body class="bg-gray-50 h-screen overflow-auto p-6">
    <div class="container mx-auto fade-in">
        <!-- 欢迎信息 -->
        <div class="flex justify-between items-center mb-6">
            <div id="nn">
                <p class="text-gray-600">今天是 <span id="currentDate"></span>，祝您工作愉快！</p>
            </div>
            <div class="text-right">
                <p class="text-sm text-gray-500">上次登录: 2023-06-15 08:30:45</p>
                <p class="text-sm text-gray-500">IP: 192.168.1.101</p>
            </div>
        </div>
    </div>

    <script>
        // 显示当前日期
        document.addEventListener('DOMContentLoaded', function() {
            const now = new Date();
            const options = { year: 'numeric', month: 'long', day: 'numeric', weekday: 'long' };
            document.getElementById('currentDate').textContent = now.toLocaleDateString('zh-CN', options);
        });

        $(function (){
            const userId = sessionStorage.getItem("userId");
            $.ajax({
                url: "${pageContext.request.contextPath}/oa.action",
                type: "POST",
                data: {
                    option: "emp",
                    userId: userId
                },
                dataType: "json",
                success: function (data) {
                    console.log(data);
                    let h1 = `<h1 class="text-2xl font-bold text-gray-800">`+ data.name +`</h1>`;
                    $("#nn").prepend(h1)
                }
            })
        })
    </script>
</body>
</html>